package com.openxt.nbzj.model;

import android.content.Context;
import android.support.multidex.MultiDexApplication;

import com.lzy.imagepicker.ImagePicker;
import com.morgoo.droidplugin.PluginHelper;
import com.morgoo.droidplugin.pm.PluginManager;
import com.openxt.nbzj.loader.PicassoImageLoader;

import org.xutils.x;

/**
 * Created by 颖杰_2 on 2016-11-19.
 */

public class OpenxtApplication extends MultiDexApplication {
    @Override
    public void onCreate() {
        super.onCreate();

        //这里必须在super.onCreate方法之后，顺序不能变
        PluginHelper.getInstance().applicationOnCreate(getBaseContext());

        x.Ext.init(this);

        /*HttpsUtils.SSLParams sslParams = HttpsUtils.getSslSocketFactory(null, null, null);
        OkHttpClient okHttpClient = new OkHttpClient.Builder()
                .sslSocketFactory(sslParams.sSLSocketFactory, sslParams.trustManager)
                .connectTimeout(5L, TimeUnit.SECONDS)
                .readTimeout(300L, TimeUnit.SECONDS)
                .build();

        OkHttpUtils.initClient(okHttpClient);*/

        //图片选择
        ImagePicker imagePicker = ImagePicker.getInstance();
        imagePicker.setImageLoader(new PicassoImageLoader());   //设置图片加载器
        imagePicker.setShowCamera(true);  //显示拍照按钮
        imagePicker.setCrop(true);        //允许裁剪（单选才有效）
        imagePicker.setMultiMode(false);
        imagePicker.setSelectLimit(1);    //选中数量限制

    }

    @Override
    protected void attachBaseContext(Context base) {
        PluginHelper.getInstance().applicationAttachBaseContext(base);
        super.attachBaseContext(base);
    }
}
